public class Matrix {

	//Source: http://introcs.cs.princeton.edu/java/22library/Matrix.java.html

	// matrix-vector multiplication (y = A * x)
	public static double[] multiply(double[][] A, double[] x) {
		int m = A.length;
		int n = A[0].length;
		if (x.length != n) {
			throw new RuntimeException("Illegal matrix dimensions.");
		}
		double[] y = new double[m];
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < n; j++) {
				y[i] += (A[i][j] * x[j]);
			}
		}
		return y;
	}
}
